﻿<%@page
	import="com.hhit.collaborative_learning.dao.impl.PublicDaoImplMySql"%>
<%@page import="com.hhit.collaborative_learning.utils.Utils"%>
<%@page import="com.mysql.jdbc.StringUtils"%>
<%@page import="java.util.Calendar"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page isELIgnored="false"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";

	String currentPageStr = request.getParameter("currentPage");
	if (StringUtils.isNullOrEmpty(currentPageStr)
			|| currentPageStr.equals("1")) {
		Calendar now = Calendar.getInstance();
		String time = Utils.getSomedaysAgo2(now);
		String[] times = time.split(";");
		Utils.expertCurrentTime = times[2];
		Utils.expertSevenDaysAgo = times[0];
		Utils.expertTwoDaysAgo = times[1];
	}
	PublicDaoImplMySql dao = new PublicDaoImplMySql();
	if (session.getAttribute("recomExpert") == null) {
		session.setAttribute("recomExpert", dao.getRecomExpert(""));
	}
	request.setAttribute("blogPage",
			dao.getExpertBlog("", currentPageStr));
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!-- <script id="allmobilize" charset="utf-8" -->
<!-- 	src="<%=basePath%>js/allmobilize.min.js"></script> -->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />


<!--new top-->
<link rel="stylesheet" href="<%=basePath%>css/index.css">
<!--new top-->

<link rel="Stylesheet" type="text/css" href="<%=basePath%>css/home.css" />
<script src="<%=basePath%>js/jquery.js" type="text/javascript"></script>
<script src="<%=basePath%>js/home.js" type="text/javascript"></script>
<script src="<%=basePath%>js/plugins.js" type="text/javascript"></script>
<script type="text/javascript">
	function checkLogin(e){
		var userId=$.cookie("userId");
		if(userId==null||userId.trim()==""){
			e.href="<%=basePath%>login.jsp?link="+encodeURIComponent($(e).attr("link"));
		}else{
			e.href="<%=basePath%>"+$(e).attr("link");
		}
	}
</script>
</head>
<body>

	<div role="banner" class="blog-nav">
		<div class="container">
			<div role="navigation" class="navbar-collapse">
				<ul class="navbar-nav">
					<li><a
						href="<%=basePath%>learning/learning.jsp" target="_top" title="">首页</a></li>
					<li class=active><a href="expert.jsp">博客专家</a></li>
					<li><a href="" class="rss" link="learning/myblog.jsp?page=bloglist" onclick="checkLogin(this)"
						target="_blank">我的专题</a></li>
					<li><a href="<%=basePath %>learning/search.jsp?type=1" target="_blank">搜索</a></li>
				</ul>
			</div>
		</div>
	</div>
	<div id="wrap">
		<div class="main_con">
			<div class="main_con">
				<div class="main_left">
					<div class="side_nav">
						<ul>
							<li class=select><a href="expert.jsp" name="all">全部分类</a></li>
							<li><a
								href="<%=basePath%>learning/expert_category.jsp?type=mobile"
								name="mobile">移动开发</a></li>
							<li><a
								href="<%=basePath%>learning/expert_category.jsp?type=web"
								name="web">Web前端</a></li>
							<li><a
								href="<%=basePath%>learning/expert_category.jsp?type=enterprise"
								name="enterprise">架构设计</a></li>
							<li><a
								href="<%=basePath%>learning/expert_category.jsp?type=code"
								name="code">编程语言</a></li>
							<li><a
								href="<%=basePath%>learning/expert_category.jsp?type=www"
								name="www">互联网</a></li>
							<li><a
								href="<%=basePath%>learning/expert_category.jsp?type=database"
								name="database">数据库</a></li>
							<li><a
								href="<%=basePath%>learning/expert_category.jsp?type=system"
								name="system">系统运维</a></li>
							<li><a
								href="<%=basePath%>learning/expert_category.jsp?type=cloud"
								name="cloud">云计算</a></li>
							<li><a
								href="<%=basePath%>learning/expert_category.jsp?type=software"
								name="software">研发管理</a></li>
<!-- 							<li><a -->
<!-- 								href="<%=basePath%>learning/expert_category.jsp?type=other" -->
<!-- 								name="other">综合</a></li> -->
						</ul>
					</div>

					<div style="margin:0 0 10px 0;">
						<a href="" onclick="checkLogin(this)" link="learning/apply_expert.jsp" target="_top"><img
							src="../css/images/join_expert.gif" alt="博客专家申请规则" /></a>
					</div>

				</div>
				<div class="page_right">
					<div class="bor_box">
						<h1>推荐专家</h1>
						<ul class="list_3" id="experts">
							<c:forEach items="${sessionScope.recomExpert}" var="expert">
								<li><dl>
										<dt>
											<a
												href='<%=basePath %>learning/personal.jsp?userId=${expert.userId}'
												target=_blank><img alt='${expert.userNickName }'
												src='<%=basePath %>userIcons/${expert.userIcon}' /></a>
										</dt>
										<dd>
											<a
												href='<%=basePath %>learning/personal.jsp?userId=${expert.userId}'
												target=_blank>${expert.userNickName } 
										</dd>
									</dl></li>
							</c:forEach>
						</ul>
					</div>
					<div class="bor_box">
						<h1>最新文章</h1>
						<c:forEach items="${requestScope.blogPage.list }" var="blog">
							<div class="blog_list">
								<h1>
									<a
										href="<%=basePath %>learning/expert_category.jsp?type=${blog.category}"
										class="category">[${blog.category_CN}]</a> <a
										name="${blog.blogId}"
										href="<%=basePath %>learning/article.jsp?blogId=${blog.blogId}&userId=${blog.userId}"
										target="_blank">${blog.blogName}</a>
								</h1>
								<dl>
									<dt>
										<a
											href="<%=basePath %>learning/personal.jsp?userId=${blog.userId}"
											target="_blank"> <img
											src="<%=basePath %>userIcons/${blog.userIcon}"
											alt="${blog.userName }" />
										</a>
									</dt>
									<dd>${blog.blogDesc}...</dd>
								</dl>
								<p>
									<c:forEach items="${blog.tag }" var="tag"></c:forEach>
									<a class="tag" href="/tag/details.html?tag=${tag }"
										target="_blank">${tag }</a>
								</p>

								<div class="about_info">
									<span class="fl"> <a
										href="<%=basePath %>learning/personal.jsp?userId=${blog.userId}"
										target="_blank" class="user_name">${blog.userName }</a> <span
										class="time">${blog.time }</span> <a
										href="<%=basePath %>learning/article.jsp?blogId=${blog.blogId}&userId=${blog.userId}"
										target="_blank" class="view">阅读(${blog.readNum })</a> <a
										href="<%=basePath %>learning/article.jsp?blogId=${blog.blogId}&userId=${blog.userId}#comments"
										target="_blank" class="comment">评论(${blog.commentNum})</a>
									</span>
								</div>
							</div>
						</c:forEach>
						<div class="page_nav">
							<c:if test="${requestScope.blogPage.totalPage>1 }">
								<span> ${requestScope.blogPage.count}条数据
									共${requestScope.blogPage.totalPage}页</span>
								<c:if test="${requestScope.blogPage.currentPage>1}">
									<a href="expert.jsp?currentPage=1">首页</a>
									<a
										href="expert.jsp?currentPage=${requestScope.blogPage.currentPage-1}">上一页</a>
								</c:if>
								<c:if test="${requestScope.blogPage.pageDiffer>0}">
									<a
										href="expert.jsp?currentPage=${requestScope.blogPage.pageDiffer*5-4}">...</a>
								</c:if>

								<c:if
									test="${requestScope.blogPage.pageDiffer*5+1<=requestScope.blogPage.totalPage}">
									<c:choose>
										<c:when
											test="${requestScope.blogPage.currentPage==requestScope.blogPage.pageDiffer*5+1 }">
											<strong>${requestScope.blogPage.pageDiffer*5+1}</strong>
										</c:when>
										<c:otherwise>
											<a
												href="expert.jsp?currentPage=${requestScope.blogPage.pageDiffer*5+1}">${requestScope.blogPage.pageDiffer*5+1}</a>
										</c:otherwise>
									</c:choose>
								</c:if>

								<c:if
									test="${requestScope.blogPage.pageDiffer*5+2<=requestScope.blogPage.totalPage}">
									<c:choose>
										<c:when
											test="${requestScope.blogPage.currentPage==requestScope.blogPage.pageDiffer*5+2 }">
											<strong>${requestScope.blogPage.pageDiffer*5+2}</strong>
										</c:when>
										<c:otherwise>
											<a
												href="expert.jsp?currentPage=${requestScope.blogPage.pageDiffer*5+2}">${requestScope.blogPage.pageDiffer*5+2}</a>
										</c:otherwise>
									</c:choose>
								</c:if>

								<c:if
									test="${requestScope.blogPage.pageDiffer*5+3<=requestScope.blogPage.totalPage}">
									<c:choose>
										<c:when
											test="${requestScope.blogPage.currentPage==requestScope.blogPage.pageDiffer*5+3 }">
											<strong>${requestScope.blogPage.pageDiffer*5+3}</strong>
										</c:when>
										<c:otherwise>
											<a
												href="expert.jsp?currentPage=${requestScope.blogPage.pageDiffer*5+3}">${requestScope.blogPage.pageDiffer*5+3}</a>
										</c:otherwise>
									</c:choose>
								</c:if>

								<c:if
									test="${requestScope.blogPage.pageDiffer*5+4<=requestScope.blogPage.totalPage}">
									<c:choose>
										<c:when
											test="${requestScope.blogPage.currentPage==requestScope.blogPage.pageDiffer*5+4 }">
											<strong>${requestScope.blogPage.pageDiffer*5+4}</strong>
										</c:when>
										<c:otherwise>
											<a
												href="expert.jsp?currentPage=${requestScope.blogPage.pageDiffer*5+4}">${requestScope.blogPage.pageDiffer*5+4}</a>
										</c:otherwise>
									</c:choose>
								</c:if>

								<c:if
									test="${requestScope.blogPage.pageDiffer*5+5<=requestScope.blogPage.totalPage}">
									<c:choose>
										<c:when
											test="${requestScope.blogPage.currentPage==requestScope.blogPage.pageDiffer*5+5 }">
											<strong>${requestScope.blogPage.pageDiffer*5+5}</strong>
										</c:when>
										<c:otherwise>
											<a
												href="expert.jsp?currentPage=${requestScope.blogPage.pageDiffer*5+5}">${requestScope.blogPage.pageDiffer*5+5}</a>
										</c:otherwise>
									</c:choose>
								</c:if>
								<c:if
									test="${requestScope.blogPage.totalPage>5 && requestScope.blogPage.pageDiffer<requestScope.blogPage.totalPage/5-1}">
									<a
										href="expert.jsp?currentPage=${requestScope.blogPage.pageDiffer*5+6}">...</a>
								</c:if>
								<c:if
									test="${requestScope.blogPage.currentPage<requestScope.blogPage.totalPage}">
									<a
										href="expert.jsp?currentPage=${requestScope.blogPage.currentPage+1}">下一页</a>
									<a
										href="expert.jsp?currentPage=${requestScope.blogPage.totalPage}">尾页</a>
								</c:if>
							</c:if>
						</div>
					</div>
				</div>
			</div>

		</div>

		<script type="text/javascript" src="<%=basePath%>js/cnick.js"></script>
		<script type='text/javascript'>
(function(){
$(function(){
	var back_top_value =Math.ceil(document.documentElement.clientHeight *0.65);
	var float_ask_img="<div data-mod='popu_64' class='tracking-ad' chg-blk='0' ><a id='com-d-top-a'  style='top:"+back_top_value+"px' title='返回顶部' onclick='' ></a> </div>";
	$("body").append(float_ask_img);
	
	var d_top = $('#com-d-top-a');

        $(document).scroll(function(){
            var scrTop = (document.body.scrollTop || document.documentElement.scrollTop);
            if (scrTop > 500)
            {
                d_top.show();
            } else
            {
                d_top.hide();
            }

        })
        $('#com-d-top-a').click(function ()
        {
            scrollTo(0, 0);
            this.blur();
            return false;
        });
});
})();
</script>
		<link href="<%=basePath%>css/ask_float_block.css" type="text/css"
			rel="stylesheet" />
	</div>
</body>
</html>
